<?php

/*******************************************************************************
 * $Date:: Jan 10, 2011 10:20:33 PM                                            $
 * $Revision:                                                                  $
 * $Author:: Hung Le                                                           $
 * $Comment::                                                                  $
 ******************************************************************************/ 
/**
 * Description here...
 * 
 * @package Lua
 * @subpackage ##Subpackage##
 * @author Hung Le <hunglevn[at]gmail[dot]com>
 * @version 
 */

class Lua_Service_Location implements Lua_Service_Interface {
    /**
     * @var Lua_Table_City
     */
    private $cityTable = null;
    
    /**
     * @var Lua_Table_Country
     */
    private $countryTable = null;
    
    public function __construct() {
        $this->cityTable = new Lua_Table_City();
        $this->countryTable = new Lua_Table_Country();
    }
    
    public function findCitiesByCountryId($countryId) {
        $query = $this->cityTable->select(true)->setIntegrityCheck(false);
        $where = $this->cityTable->getAdapter()->quoteInto('country_id = ?', $countryId);
        
        $query->where($where);
        $query->order('name ASC');
        
        $baseTable = new Lua_Table_Base();
        $cities = $baseTable->findAll('ipoo_city', $query);
        return $cities;
    }
    
    public function findAllCountries() {
        $query = $this->countryTable->select(true)->setIntegrityCheck(false);
        $baseTable = new Lua_Table_Base();
        $countries = $baseTable->findAll('ipoo_country', $query);
        return $countries;
    }
    
}    